//动态导入json数据
	
var xmlRequest = createXHQ();

var userid = "";
var shopid = "";

xmlRequest.open("GET","../json/addSSuccess.json");
xmlRequest.send();

xmlRequest.onreadystatechange=function(){
	
	if(xmlRequest.readyState===4){
		if(xmlRequest.status===200){
			var result1 = xmlRequest.responseText;
			var resultObject = JSON.parse(result1);	
			
			userid = resultObject.userId;
			shopid = resultObject.shop_id;
			
			var userLogin = document.getElementById("user");
			if(resultObject.userName!=null&&resultObject.userName!=""){
				userLogin.innerHTML=resultObject.userName;
				userLogin.href="../user_more.html";
			}else{
				userLogin.innerHTML="请登陆";
				userLogin.href="../login.html";
			}
			
			var f_div = document.getElementById("main");
			var z_main=	"<div>"+
							"<span class='m-t1'>商品已成功加入购物车！</span>"+
							"<div class='shopping'>"+
								"<div class='image-shopping'>"+
									"<img src="+ resultObject.img_big +" />"+
									
								"</div>"+
								"<div class='title-shopping'>"+
									"<span class='s-t1'><a href="+ "#?id=" +resultObject.shop_id +">"+ resultObject.shop_title  +"</a></span>"+
									"<span class='s-t2'>数量："+ resultObject.shopNum +"</span>"+
								"</div>"+
								"<div class='btn-shopping'>"+
									"<input type='button' class='s-btn1' value='查看商品详情' />"+
									"<input type='button' class='s-btn2' value='去购物车结算>' />"+
								"</div>"+
							"</div>"+
						"</div>";
			f_div.innerHTML=z_main;
				
			
		}else{
			alert("错误信息："+xmlRequest.status);
		}
	}
}

window.onload=function(){
	
	document.getElementsByClassName("s-btn1")[0].onclick=function(){
		window.location.href='../informationShopp.html?shopid='+shopid;
	}
	
	document.getElementsByClassName("s-btn2")[0].onclick=function(){
		window.location.href='../result1/shopping_cart.html?userid='+userid;
	}
}